{extend name="common/base" /}

{block name="style"}
<link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm-extend.css">

<style>
    body{
        background: #F5F5F5;
    }
    .qrdd-top .qrdd-top-nav li{
        width: auto;
    }
    .js-hide{
        display:none;
    }
</style>
{/block}
{block name="body"}
<div class="jzzf-mains qrdd-mains">
    <div class="qrdd-top">
        <h2 class="qrdd-top-h2">已选商品（{$cart.num}）</h2>
        <ul class="qrdd-top-nav">
            {foreach $list as $vo }

            <li class="goods-item {eq name="$vo['hide']" value="1"}js-hide{/eq}" >
                <div class="div1">【{$vo.brand_title}】{$vo.goods_title}{notempty name="$vo.goods_model"},{$vo.goods_model}{/notempty}{notempty name="$vo.goods_spec"},{$vo.goods_spec}{/notempty}</div>
                            <div class="div2">x{$vo.buy_num}</div>
                            <div class="div3">{$vo.selling_price}元</div>
                        </li>
                        {/foreach}
            </ul>
            {notpresent name="is_hide"}
            <div class="qrdd-top-zk" data-type="0">展开更多</div>
            {/notpresent}
            <!--<div class="qrdd-top-zk">收起</div>--> 
        </div>
        <div class="qrdd-center">
            <div class="qrdd-center-o">
                <span class="span1">优惠券</span>
                <!-- class加上span-ky则为有可用优惠券的状态 -->
                {notpresent name="coupon_info"}
                {gt name="coupon_num" value="0"}
                <span class="span2 span-ky js-sel-coupon">{$coupon_num}张可用</span>
                {else/}
                <span class="span2">无可用优惠券</span>
                {/gt}
                {else /}
                 <span class="span2 span-ky">{$coupon_info.coupon_name}</span>
                {/notpresent}
            </div>
            <div class="qrdd-center-o">
                <span class="span1">积分<i>（{$user_info.score}积分,可抵扣{$user_info.dikou}元）</i></span>
                <input type="hidden" class="dikou" value="{$user_info.dikou}">
                <img src="__CDN__/html/img/hz-img15.png" class="cen-img js-score-dikou" data-dikou="0" {neq name="score" value="0"}style='display:none;'{/neq} >
                     <img src="__CDN__/html/img/hz-img12.png" class="cen-img js-score-dikou" data-dikou="1" {eq name="score" value="0"}style='display:none;'{/eq}>
            </div>
        </div>
        <ul class="qrdd-nav">
            <li>
                <span class="span1">商品总额</span>
                <span class="span2 spans">{$cart.total_price}元</span>
            </li>
            <li>
                <span class="span1">优惠券抵扣</span>
                <span class="span2">-{$par_value}元 </span>
            </li>
            <li>
                <span class="span1">积分抵扣</span>
                <span class="span2 js-dikou">-{$score}元 </span>
            </li>
            <li>
                <span class="span1">满减</span>
                <span class="span2">-0元 </span>
            </li>                        
        </ul>

        <div class="swiper-container con-top" >
            <!-- Additional required wrapper -->
            <div class="swiper-wrapper">
                <!-- Slides -->
                {foreach $banner_list as $vo }
                <div class="swiper-slide">
                    {if ($vo['jump_type']==1)}
                    <a href="{$vo.ad_link}">
                        {/if}
                        <img src="__OSSCDN__{$vo.ad_img}" />
                        {if ($vo['jump_type']==1)}
                    </a>
                    {/if}
                </div>
                {/foreach}
            </div>
        </div>

    </div>

    <div class="qrdd-fixed">
        <input type="hidden" class="js-total" value="{$cart.total_price}">
        <input type="hidden" class="js-score-dikou" value="{$is_score}">
        <input type="hidden" class="js-coupon-id" value="{$coupon_id}">
        <div class="qrdd-zi">应付：<i class="js-total-price">{$cart.total_price}元</i></div>
        <div class="qrdd-butt">立即下单</div>
    </div>
    {/block}
    {block name="script"}
    <script src="__CDN__/html/js/swiper.js"></script>

    <script>
        $(".swiper-container").swiper({
            loop: true,
            autoplay: 3000
        });

        $('.js-score-dikou').on('click', function () {
            var dikou = $(this).attr('data-dikou');
            var total = $('.js-total').val();
            $('.js-score-dikou').show();
            $(this).hide();
            var price = $('.dikou').val();
            if (dikou == 0) {
                $('.js-dikou').html('-' + price + '元');
                total = total - price;
                $('.js-score-dikou').val(1);

            } else {
                $('.js-dikou').html('-0元');
                $('.js-score-dikou').val(0);
            }
            $('.js-total-price').html(total + '元');

        });

        $('.js-sel-coupon').on('click', function () {
            var dikou = $('.dikou').val();
            var jump_url = "{:url('selCoupon',array('score'=>'OD'))}";
            jump_url = jump_url.replace('OD', dikou);
            location.href = jump_url;
        });



        $('.qrdd-top-zk').on('click', function () {

            var type = $(this).attr('data-type');
            if (type == 0) {
                type = 1;
                $('.js-hide').show();
                $(this).html('收起');
            } else {
                type = 0;
                $('.js-hide').hide();
                $(this).html('展开更多');
            }

            $(this).attr('data-type', type);

        });

        $('.qrdd-butt').on('click', function () {
            var is_score = $(".js-score-dikou").val();
            var coupon_id = $(".js-coupon-id").val();
            //优惠券ID

            $.post("{:url('Order/add')}", {is_score: is_score, coupon_id: coupon_id}, function (res) {
                if (res.code == 1) {
                    location.href = res.data.url;
                } else {
                    mui.alert(res.msg);
                }
            }, 'json');
        });
    </script>
    {/block}